#include "include/cxxstd.h"
#include "include/config.h"
#include "ABIBase.h"

using namespace zero;

namespace std
{
bad_alloc::bad_alloc() throw()
{
}

bad_alloc::~bad_alloc() throw()
{
}

const char* bad_alloc::what() const throw()
{
  return "std::bad_alloc";
}

EXPORT_CLASS_TYPEINFO(_ZTVSt9bad_alloc, _ZTISt9bad_alloc);
}

void* operator new(std::size_t sz) throw (std::bad_alloc)
{
	void *p;

	if (sz == 0)
		sz = 1;
	p = ABIBase::current()->newHandler(sz);
	if (!p)
		throw std::bad_alloc();

	return p;
}
EXPORT_CXX_TEXT(_Znwj);

void* operator new[](std::size_t sz) throw (std::bad_alloc)
{
	return ::operator new(sz);
}
EXPORT_CXX_TEXT(_Znaj);

void operator delete(void* ptr) throw ()
{
	if (ptr)
		ABIBase::current()->deleteHandler(ptr);
}
EXPORT_CXX_TEXT(_ZdlPv);

void operator delete[](void* ptr) throw ()
{
	::operator delete(ptr);
}
EXPORT_CXX_TEXT(_ZdaPv);
// vim: foldmarker=<([{,}])> foldmethod=marker
